function outStru=checkCellOverlap(cellPivot,varargin) 
%% function outStru=checkCellOverlap(cellPivot,varargin) 
% Given a variable number of cell of strings, cellPivot is the one to compare against, and 
% check wether its elements are members of the cells in varargin. 
% Use for instance to check for repeated names when declaring symbolic
% objects 
% 
%% Output 
% *outStru:* structure which subfields 
% .flagOverlap==true or false 
% .cell<j>     either empty or indicating the position of the elements in
%              cell<j> that are in cellPivot 
% 
% Alejandro Justinano January 11 2013 
% =========================================================================
%cellPivot=varargin{1}; 
NPivot=length(cellPivot); 
outStru.flagOverlap=false;
for ii=1:nargin-1;
    fldnm=['Cell',num2str(ii)];
    vecOverlap=zeros(length(varargin{ii}),1);
    for jj=1:NPivot;
        if any( strcmp(cellPivot{jj},varargin{ii})~=0)==true
            vecOverlap(jj)=1;
        end
    end
    if sum(vecOverlap)~=0
        vecOverlap=vecOverlap( vecOverlap~=0 );
        outStru.(fldnm)=vecOverlap;
        outStru.flagOverlap=true;
        dispaj('Overlap in cell #',num2str(ii),' in #',length(vecOverlap),' elements'); 
    else
        outStru.(fldnm)=[];        
    end
end 

end 